package com.vrv.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.vrv.entity.AdminInfo;
import com.vrv.entity.UserInfo;
import com.vrv.service.MenuService;
import com.vrv.utils.AdminUtil;

@Controller
@RequestMapping("/main")
public class MainConfigurationController {
    @Autowired
    private MenuService menuService;

    @Autowired
    private HttpServletRequest request;

    @RequestMapping("/mainConfriguation")
    public String list() {
        return "/main/mainConfriguation";
    }

    @RequestMapping("/index")
    public String index(ModelMap model) {
        int type = AdminUtil.getType(request);
        model.put("type", type);
        if (type == 2) {
            model.put("userInfo", new UserInfo());
            return "index";
        }
        if (type == 0) {
            UserInfo userInfo = (UserInfo) AdminUtil.getAdmin(request);
            model.put("userInfo", userInfo);
        } else {
            AdminInfo userInfo = (AdminInfo) AdminUtil.getAdmin(request);
            model.put("userInfo", userInfo);
        }
        model.put("menuList", menuService.showMenuList(request));
        return "index";
    }
}
